<?php

/**
 * @Author: Wang chunsheng  email:2192138785@qq.com
 * @Date:   2023-05-07 09:34:15
 * @Last Modified by:   Wang chunsheng  email:2192138785@qq.com
 * @Last Modified time: 2023-05-09 17:29:36
 */

namespace Common\Models\sys;

use Common\BaseModel;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\ModelCache\Cacheable;
use Hyperf\ModelCache\CacheableInterface;

/**
 * 项目主表.
 *
 * @date 2023-05-07
 *
 * @example
 *
 * @author wang chunSheng
 *
 * @since
 */
class SysProject extends BaseModel  implements CacheableInterface
{
    use Cacheable;

    protected ?string $table = 'sys_project';

    protected array $fillable = ['title','desc','domain','member_id','app_id','app_secret','project_sn','loopback_address'];

    public function device(): HasMany
    {
        return $this->hasMany(SysDevice::class, 'id', 'project_id');
    }

    /**
     * 缓存 10 分钟，返回 null 则使用配置文件中设置的超时时间
     * @return int|null
     */
    public function getCacheTTL(): ?int
    {
        return 6000;
    }
}
